package com.quwan.common.enums;

/**
 * @author lt
 * @Date 2021/12/10 3:04 下午
 */
public enum EnvironmentEnum {
    product("生产", new Byte((byte)0)),
    dev("开发", new Byte((byte)1));

    private String msg;
    private Byte code;

    private EnvironmentEnum(String msg, Byte code) {
        this.msg = msg;
        this.code = code;
    }
    public static String getMsgByCode(Byte code){
        EnvironmentEnum[] enums = EnvironmentEnum.values();
        for (EnvironmentEnum environmentEnum:enums){
            if(environmentEnum.getCode().equals(code)){
                return environmentEnum.getMsg();
            }
        }
        return "";
    }

    public static boolean isValidCode(Byte code) {
        for (EnvironmentEnum environmentEnum : EnvironmentEnum.values()) {
            if (code.equals(environmentEnum.getCode())) {
                return true;
            }
        }
        return false;
    }

    public String getMsg() {
        return msg;
    }

    public Byte getCode() {
        return code;
    }
}
